package demo34;

import java.util.concurrent.*;

/**
 * new一个线程池然后然后提交Callable的实现的对象。使用Future来获得Callable的返回值。
 */
public class MyFuture02 {
    public static void main(String[] args) throws InterruptedException, ExecutionException {

        ExecutorService service = Executors.newFixedThreadPool(5);
        Future<Integer> f = service.submit(() -> {
            TimeUnit.MILLISECONDS.sleep(500);
            return 1;
        });
        System.out.println(f.get());
        System.out.println(f.isDone());

    }
}